<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}"  media="all">
</head>
<body>

<table class="layui-hide" id="test" lay-filter="test"></table>

<div  id="open1" style="display: none;position: absolute;top: 20px;left: 30px">
    <div >
        <form class="layui-form" id="addEmployeeForm"  th:action="@{/cinemaVip/addVip}" method="post">
            <div class="layui-form-item" >
                <label class="layui-form-label">VIP名称:</label>
                <div class="layui-input-block" style="width: 300px">
                    <input type="text"  class="layui-input"  id="vname" onblur="check1()" name="vname">
                </div>
            </div>

            <div class="layui-form-item" >
                <label class="layui-form-label">优惠:</label>
                <div class="layui-input-block" style="width: 300px">
                    <!--required lay-verify="required | number"-->
                    <input type="text"  id="vdiscount" class="layui-input" name="vdiscount" onblur="check2()" lay-reqtext="输入格式错误" placeholder="请输入优惠，例：0.9">
                </div>
            </div>
        </form>
    </div>
</div>

<script type="text/html" id="toolbarDemo">
   <!-- <div class="layui-btn-container">

        <button class="layui-btn layui-btn-sm" lay-event="add">添加VIP</button>

    </div>-->
</script>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">已经处理</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script th:src="@{/layui/layui.js}" charset="utf-8"></script>
<script th:src="@{/js/jquery.min.js}" charset="utf-8"></script>
<script th:inline="javascript">
    var url=[[@{/}]]
</script>
<script th:inline="none">
    //var layer = layui.layer;
    layui.use('table', function(){
        var table = layui.table;
        var layer = layui.layer;
        table.render({
            elem: '#test'
            ,url:url+'problem/showProblem'
            ,toolbar: '#toolbarDemo'
            ,title: '问题反馈信息'
            ,limit:2
            ,id:'tab'
            ,cols: [[
                {type: 'checkbox', fixed: 'left'}
                ,{field:'problemId', title:'ID', width:80, fixed: 'left', unresize: true, sort: true}
                ,{field:'solveTheProgress', title:'解决进度', width:120, edit: 'text',sort: true}
                ,{field:'problemInfo', title:'问题详细信息', width:240, edit: 'text' }
                ,{field:'problemImg', title:'问题建议', width:120}
                ,{field:'problemDate', title:'提交日期', width:160,  sort: true}
                ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
            ]]
            ,page: true
        });

        //头工具栏事件
        table.on('toolbar(test)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);

        });

        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            if(obj.event === 'del'){

                if(data.solveTheProgress == '正在处理'){
                    layer.confirm('确认删除吗，问题未处理,', function(index){
                        obj.del();
                        $.ajax({//删除用户的请求
                            url:url+"problem/deleProblem",
                            data:{"problemId":data.problemId},
                            success:function (resultDate) {
                                //  layer.msg("提示信息",resultDate);
                                if(resultDate == "success"){
                                    layer.msg('删除成功');
                                    //alert("删除成功")
                                    table.reload('tab',{
                                        url:url+'problem/showProblem'
                                    });
                                }else{
                                    layer.msg('删除失败');
                                }
                            }
                        })
                        layer.close(index);
                    });
                }else{
                    obj.del();
                    $.ajax({//删除用户的请求
                        url:url+"problem/deleProblem",
                        data:{"problemId":data.problemId},
                        success:function (resultData) {
                            //  layer.msg("提示信息",resultDate);
                            layer.msg(resultData)
                            if(resultData == "success"){
                                layer.msg('删除成功');
                                table.reload('tab',{
                                    url:url+'problem/showProblem'
                                });
                            }else{
                                layer.msg('删除失败');
                            }
                        }
                    })
                    //layer.close(index);
                }

            } else if(obj.event === 'edit'){
                $.ajax({
                    url:url+'problem/solveProblem',
                    data:{'problemId':data.problemId},
                    success:function (result) {
                        table.reload('tab',{
                            url:url+'problem/showProblem'
                        });
                            layer.msg('修改成功');
                    }
                })
            }
        });
    });


</script>
</body>
</html>